/*
*       A simple 2D game map editor
*
*       This library is free software; you can redistribute it and/or
*       modify it under the terms of the GNU Lesser General Public
*       License as published by the Free Software Foundation; either
*       version 2.1 of the License, or (at your option) any later version.
*/
// Name        : map
// File        : map.cpp
// Description :
// Author      : hoha
// Date        : 01/07/2009
// Evolutions  : 01/07/2009, Version V0, Creation
#include "map.h"
int map_layer;
map_t gmap[MAX_MAP_WIDTH][MAX_MAP_HEIGHT];

void init_map()
{
	map_layer = MAP_LAYER0;
	for(int i =0; i < MAX_MAP_WIDTH; i++)
	{
		for(int j =0; j< MAX_MAP_HEIGHT; j++)
		{
			gmap[i][j].tileId_L0 = NS_TILE_ID_MAP;
			gmap[i][j].tileId_L1 = NS_TILE_ID_MAP;
			gmap[i][j].is_barrier = false;
		}
	}
}

void fill_tile_in_map(int tileId, int mapX, int mapY, int mapLayer)
{
	switch(mapLayer)
	{
		case MAP_LAYER0:
	         gmap[mapX][mapY].tileId_L0 = tileId;
			 break;
		case MAP_LAYER1:
	         gmap[mapX][mapY].tileId_L1 = tileId; 
			 break;
		default:
		     break;
	}
}

void erase_tile_in_map(int mapX, int mapY, int mapLayer);
{
	switch(mapLayer)
	{
		case MAP_LAYER0:
	         gmap[mapX][mapY].tileId_L0 = NS_TILE_ID_MAP;
			 break;
		case MAP_LAYER1:
	         gmap[mapX][mapY].tileId_L1 = NS_TILE_ID_MAP; 
			 break;
		default:
		     break;
	}
}

void mark_tile_as_barrier(int mapX, int mapY);
{
	if(NS_TILE_ID_MAP!=gmap[mapX][mapY].tileId_L0)
	{
	    gmap[mapX][mapY].is_barrier = true;
	}
	else
	{
        printf("map error: cannot mark a un-existed tile\n");
	}
}

void mark_tile_as_normal(int mapX, int mapY);
{
	if(NS_TILE_ID_MAP!=gmap[mapX][mapY].tileId_L0)
	{
	    gmap[mapX][mapY].is_barrier = false;
	}
	else
	{
        printf("map error: cannot mark a un-existed tile\n");
	}
}
